/**
 * @Author       : Hejh(3010733382@qq.com)
 * @Version      : V1.0
 * @Date         : 2024-01-29 12:42:55
 * @Description  : 通知管理相关接口
 */
import type {
  NoticeCreateReq,
  NoticePageRes,
  NoticeReq,
  NoticeRes,
  NoticeUpdateReq
} from '@/types/notice'
import request from '@/utils/request'

// 分页查询通知接口
export const getNoticeByPage = (params?: NoticeReq) => {
  return request.get<NoticePageRes>('/notice/list', { params })
}

// 前台用户查询通知接口
export const getUserNotices = () => {
  return request.get<NoticeRes[]>('/notice/user/list')
}

// 用户已读通知接口
export const readNotice = (data: { noticeId: string }) => {
  return request.post('/notice/read', data)
}

// 添加通知接口
export const createNotice = (data: NoticeCreateReq) => {
  return request.post('/notice/create', data)
}

// 更新通知接口
export const updateNotice = (data: NoticeUpdateReq) => {
  return request.put('/notice/update', data)
}

// 通知排序接口
export const sortNotice = (noticeIds: string[]) => {
  return request.put('/notice/sort', { noticeIds })
}

// 通知删除接口
export const delNotice = (noticeIds: string[]) => {
  return request.delete('/notice/delete', { data: { noticeIds } })
}
